import sys
from PIL import Image,ImageSequence
import os


##print(sys.argv[0])
##print(sys.argv[1])

def gifresize(file_name):

    gf = Image.open(file_name)
##    lifetime = gf.info['duration']

    imglist = []
    imgnew = []
    for i in ImageSequence.Iterator(gf):
        imglist.append(i.copy())

    for index,f in enumerate(imglist):
        f.save("gif\\%d.png" %index)
        img = Image.open("gif\\%d.png" %index)
        img = img.resize((80,40),Image.ANTIALIAS)
##        img.thumbnail((80,40),Image.ANTIALIAS)
        imgnew.append(img)

    imgnew[0].save("new.gif",'gif',save_all=True,append_images = imgnew[1:],loop = 0)

if __name__ == "__main__":

    gifresize("emo6.gif")        

